package cn.eleven.service.impl;

import cn.eleven.entity.Job;
import cn.eleven.mapper.JobMapper;
import cn.eleven.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class JobServiceImpl implements JobService {

    @Autowired
    private JobMapper jobMapper;

    @Override
    public List<Job> getAllJobs() {
        // 调用 MyBatis-Plus 提供的 selectList 方法查询所有数据
        return jobMapper.selectList(null);
    }

    @Override
    @Transactional
    public boolean save(Job job) {
        System.out.println("Saving job: " + job); // 添加日志输出
        return jobMapper.insert(job) > 0;
    }
}
